package cn.ulc.socket.weapp.service.impl;

import cn.ulc.common.constant.PubDataConstant;
import cn.ulc.common.constant.enums.AvailableStatus;
import cn.ulc.socket.weapp.common.BaseService;
import cn.ulc.socket.weapp.model.dto.NoticeListDTO;
import cn.ulc.socket.weapp.service.NoticeServ;
import cn.ulc.store.dao.NoticeDao;
import cn.ulc.store.dao.PubDataDao;
import cn.ulc.store.entity.Company;
import cn.ulc.store.entity.Notice;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class NoticeServImpl extends BaseService implements NoticeServ {
    NoticeDao noticeDao;
    PubDataDao pubDataDao;
    @Override
    public NoticeListDTO findNoticeByCategory(Long categoryId) {
        Company company = getCurrentCompany();
        String code = pubDataDao.findCodeByTypeAndName(PubDataConstant.DATA_TYPE_NOTICE_LOCATION,"分类公告");
        List<Notice> noticeList = noticeDao.findByCategoryId(company.getId(),categoryId,code,AvailableStatus.AVAILABLE);
        return new NoticeListDTO(noticeList);
    }
}
